package com.example.springboottools.utils.image;

import org.apache.commons.imaging.Imaging;
import org.apache.commons.imaging.common.ImageMetadata;


import java.io.File;
import java.util.List;

public class MetadataReader {

    public static void printMetadata(String filePath) {
        try {
            File imageFile = new File(filePath);
            ImageMetadata metadata = Imaging.getMetadata(imageFile);

            if (metadata != null) {
                //List<ImageMetadata.ImageMetadataItem> items = metadata.getItems();
                List<? extends ImageMetadata.ImageMetadataItem> items = metadata.getItems();
                for (ImageMetadata.ImageMetadataItem item : items) {
                    System.out.println("Metadata: " + item);
                }
            } else {
                System.out.println("No metadata found.");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        String imagePath = "C:\\Users\\SH102909\\Downloads\\cn8800193554EA_6_1xnl.jpg"; // 请替换为您的图片路径
        printMetadata(imagePath);
    }
}